<template>
	<div class="container">
		<router-link
		tag="div"
		to="/"
		class="header-icon"
		v-show="showHeader">
			<div class="iconfont header-back-icon">&#xe624;</div>
		</router-link>
		<div class="header-content" v-show="!showHeader" :style="opacityStyle">
			深圳平安金融中心云际观光层
			<router-link to="/">
				<div class="iconfont header-content-back">&#xe624;</div>
			</router-link>
		</div>
	</div>
</template>

<script>
export default {
	name: 'DetailHeader',
	data () {
		return {
			showHeader:true,
			opacityStyle: {
				opacity: 0
			}
		}
	},
	activated () {
		window.addEventListener('scroll',this.handleScroll)
	},
	deactivated () {
		window.removeEventListener('scroll',this.handleScroll)
	},
	methods: {
		handleScroll () {
			const top = document.documentElement.scrollTop
			if(top > 5) {
				let opacity = top/160
				opacity = (opacity > 1)?1:opacity
				this.opacityStyle = { opacity }
				this.showHeader = false
			} else {
				this.showHeader = true
			}
		}
	}
}
</script>

<style lang="stylus" scoped>
@import '~styles/varibles.styl'
	.header-icon
		position absolute
		left .1rem
		top .1rem
		height .72rem
		width .72rem
		border-radius .36rem
		background-color rgba(97,59,51,1)
		text-align center
		.header-back-icon
			color #fff
			line-height .72rem
	.header-content
		height $headerHeight
		line-height $headerHeight
		background $bgColor
		text-align center
		font-size .32rem
		overflow hidden
		color #fff
		position fixed
		top 0
		left 0
		right 0
		.header-content-back
			width .64rem
			text-align center
			color #fff
			position absolute
			top 0
			left 0
			font-size .4rem
</style>
